#title "Templates" When you build a site with Frontier it's done thru a template. The template defines the wrapper for each web page. It says what text surrounds the body of the page. If you design your templates well, form is separated from content. You can create lots of text files that have very little structure in them, and flow them all thru a template. When you want to change the format of each page on the site, just change the template and rebuild the site. Templates also make it easy to factor out overhead tags in HTML text, things like <body>, <head>, <title>. Editors and writers will probably appreciate this. But it's up to the sysop to determine how much or how little of the look of a page is controlled by the rendering process.

#template.html

Every website has a template file called #template.html. The # at the beginning of its name signifies that it's an attribute of the site, not part of the site itself. This leaves room for growth, we can have other attribute files as part of a website, and it makes for easy compatibility with the Frontier site framework. The file has a .html extension so that BBEdit knows to use color coding as you're editing the file.

Locating the template file

When you render a page, Frontier looks for the template file in the same folder as the file. If it doesn't find it there, it pops out a level and looks there. It keeps popping out until it reaches the desktop. So if you want to use a different template in a sub-folder on your site, just place a different #template.html file in that folder. Some commands key off the location of the template file. When you choose the Backup Site command, it copies all the files and sub-folders of the folder that contains the template file. Same with the Render Whole Site command.

Converting an existing site

Look for the common structure in all the pages, and put that into the template, and delete it from each of the files. This can be a tedious manual job, but there's no way to avoid it. Once you've made the conversion, changing the look of your site will be automatic.

Page attributes

Open the files for this website, and have a look. They all contain HTML code, but mostly they're text files. But there's something new at the top of each page, a line that begins with #title and has a quoted string containing the title of the page. Open the template file for this site, and look at the top of the file:
<html>
<head>
<title>BBEdit & Frontier: \{title}</title>
The \{title} macro "picks up" the #title attribute for each page. That's a key idea. The attribute architecture is open to you. You can establish conventions for your content, add attributes like #author and #posttime, for example, and pick them up in the template. If you want to see a complete list of attributes which are available to you (some are automatically managed by Frontier) choose websites.#data from the Open In Frontier sub-menu.